﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shop.Application.Orders;
using Shop.Application.Orders.Dto;
using Shop.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shop.UI.API
{
    [Route("API/[controller]")]
    public class OrderController : Controller
    {
        private DBContext _context;

        public OrderController(DBContext context)
        {
            _context = context;
        }

        [HttpPost("CreateOrder")]
        public IActionResult CreateOrder([FromBody] OrderInput input) => Ok(new CreateOrder(_context,HttpContext.Session).Do(input));

        [HttpGet("GetOrderByID")]
        public IActionResult GetOrderByID() => Ok(new GetOrderByOrderID(_context).Do(Guid.NewGuid()));

        [HttpGet("GetOrderByName")]
        public IActionResult GetOrderByName(string name) => Ok(new GetOrdersByUserName(_context).Do(name));

        [HttpDelete("DeleteOrder")]
        public IActionResult DeleteOrder(Guid id) => Ok(new DeleteOrder(_context).Do(id));
    }
}
